home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3
/
CHAPTE20
/
EX7.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-22
|
3KB
|
64 lines
#include <genstub.c>
// WndProc Window message procedure
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static TCHAR szOldConfiguration[33];
switch (uMsg) // Process Windows messages.
{
case WM_CREATE:
GetProfileString( "Ports", // Section Name
"COM1:", // Key Name
"9600,n,8,1,x" , // Default COM1 settings
szOldConfiguration, // Old configuration buffer.
32 ); // Buffer Size
return DefWindowProc( hWnd, uMsg, wParam, lParam );
case WM_COMMAND: // Process the menu items.
switch ( LOWORD( wParam ) )
{
case IDM_TEST: // Write the tick count to the INI file
WriteProfileString( "Ports", // Section Name.
"COM1:", // Key Name.
"14400,n,8,1,x" ); // New configuration.
InvalidateRect( hWnd, NULL, TRUE );
UpdateWindow( hWnd );
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
TCHAR szBuffer[128];
TCHAR szCurrentConfiguration[33];
BeginPaint( hWnd, &ps );
wsprintf( szBuffer, "Old Configuration: %s", szOldConfiguration );
TextOut( ps.hdc, 0, 0, szBuffer, lstrlen( szBuffer ) );
GetProfileString( "Ports", // Section Name
"COM1:", // Key Name
"9600,n,8,1,x" , // Default COM1 settings
szCurrentConfiguration, // Input buffer.
32 ); // Buffer Size
wsprintf( szBuffer, "Current Configuration: %s",
szCurrentConfiguration );
TextOut( ps.hdc, 0, 20, szBuffer, lstrlen( szBuffer ) );
EndPaint( hWnd, &ps );
}
break;
case WM_DESTROY:
WriteProfileString( "PORTS", // Section Name.
"COM1:", // Key Name.
szOldConfiguration ); // Value to restore.
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
return( 0L );
}
#include <about.c>